<?php

use yii\db\Migration;
use yii\db\Schema;

/**
 * Class m210423_114421_CREATE_DB_X
 */
class m210423_114421_CREATE_DB_X extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {

        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

         // 疫情信息表 
        $this->createTable('epidemic', [
            "id" => Schema::TYPE_PK,
            "ep_date" => Schema::TYPE_DATE. " NOT NULL COMMENT '日期'",
            "epnum_1" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '现有确诊'",
            "epnum_2" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '无症状'",
            "epnum_3" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '现有疑似'",
            "epnum_4" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '现有重症'",
            "epnum_5" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '累计确诊'",
            "epnum_6" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '境外输入'",
            "epnum_7" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '累计治愈'",
            "epnum_8" =>   Schema::TYPE_INTEGER. "(12) DEFAULT 0 NULL COMMENT '累计死亡'",
            "status" =>         Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "create_time"=>     Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>     Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m210423_114421_CREATE_DB_X cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m210423_114421_CREATE_DB_X cannot be reverted.\n";

        return false;
    }
    */
}
